package com.woniu.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class ResponseResult<T> {

    private Integer code;
    private String msg;
    private T data;

    public static final ResponseResult<Void> SUCCESS =
            new ResponseResult<>(200,"登录成功");
    public static final ResponseResult<Void> FAIL =
            new ResponseResult<>(2000,"登录失败");
    public static final ResponseResult<Void> NOLOGIN =
            new ResponseResult<>(2001,"未登录,请先登录");
    public static final ResponseResult<Void> NOAUTH =
            new ResponseResult<>(2002,"无权限,请联系管理员");
    public static final ResponseResult<Void> LOGOUT =
            new ResponseResult<>(2003,"退出成功");

    public ResponseResult<T> ok(T t){
        return new ResponseResult<T>(200,t);
    }
    public ResponseResult<T> ok(){
        return new ResponseResult<T>(200,"操作成功");
    }

    public ResponseResult(Integer code, T data) {
        this.code = code;
        this.data = data;
    }

    public ResponseResult(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }
}
